package com.rr.learningdemo.redis;

import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.stereotype.Component;

import java.nio.charset.StandardCharsets;

@Component
public class RedisListener implements MessageListener {
    /**
     * 监听到指定数据库的数据的回调方法
     *
     * @param message
     * @param pattern
     */
    @Override
    public void onMessage(Message message, byte[] pattern) {
        System.out.println("监听指定数据库的数据--------------------" + new String(message.getBody(), StandardCharsets.UTF_8));
    }
}
